﻿using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
//using System.Threading.Tasks;

namespace Urd.Common
{
    public static class debug
    {
        
        public enum loglevel 
        {
            Errors,
            Warnings,
            Status
        }
        static public int Capacity = 200;
        static loglevel LogLevel = loglevel.Status;
        static Queue<string> log=new Queue<string>();
      
        public static void Log(string s,loglevel ll)
        {
            if ((int)ll <= (int)LogLevel)
            {
                lock (log)
                {
                    if (log.Count <= Capacity)
                        log.Enqueue(s);
                    else
                    {
                        log.Dequeue();
                        log.Enqueue(s);
                    }
                }
            }
        }
        public static string Info 
        {
            get 
            {
                lock (log)
                {
                    string ret="";
                    foreach (string s in log) 
                    {
                        ret += s + "\n";
                    }
                    return ret;
                }
            }
        }
        public static string ByName(string name)
        {
           
                lock (log)
                {
                    string ret = "";
                    foreach (string s in log)
                    {
                        if(s.Contains(name))
                        ret += s + "\n";

                    }
                    return ret;
                }
           
        }
        
    }
}
